package org.dromara.system.enums;


import org.springframework.util.StringUtils;

/**
 * Created by fly on 2014/12/11.
 */
public enum AppCodeEnum {
    /**
     *
     */
    mapp("mapp", "菲橙AI个人", "mfc", "weixin", null, "mfcofficial", ""),

    mfcapp("mfcapp", "菲橙AI助手", "mfc", "weixin", null, "mfcofficial", null);


    AppCodeEnum(String code, String desc, String sys, String pay, String parentAppCode, String publicAppCode, String pcode) {
        this.code = code;
        this.desc = desc;
        this.sys = sys;
        this.pay = pay;
        this.parentAppCode = parentAppCode;
        this.publicAppCode = publicAppCode;
        this.pcode = pcode;
    }


    String code;
    String desc;
    String sys;

    String pay;

    String parentAppCode;

    String publicAppCode;

    String pcode;


    public static Boolean check(String code, String sys) {
        for (AppCodeEnum appCode : AppCodeEnum.values()) {
            if (appCode.getCode().toLowerCase().equals(code) &&
                appCode.getSys().toLowerCase().equals(sys)) {
                return true;
            }
        }
        return false;
    }

    public static AppCodeEnum valueOfCode(String code) {

        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (AppCodeEnum status : AppCodeEnum.values()) {
            if (status.getCode().toLowerCase().equals(code.toLowerCase())) {
                return status;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getSys() {
        return sys;
    }

    public String getPay() {
        return pay;
    }

    @Override
    public String toString() {
        return code + ":" + desc;
    }

    public String getParentAppCode() {
        return parentAppCode;
    }

    public String getPcode() {
        return pcode;
    }

    public String getPublicAppCode() {
        return publicAppCode;
    }
}
